jQuery.fn.extend({
	 //反选
	 antiselected: function(obj,options) {
		  	$(obj).bind('click', function() {
		  		var defaults = {
		  		  	tableid:'.tableborder',
		  		    cookieid:'Select_Id_list',
		  		  	type: 'checkbox'
			  	};
		  		$.extend(defaults,options);
		  		
		  		//先取得到cookie值
		  	    var  oldidlist=newidlist=new Array();
		  	    var  newidstring=newkey=Arrlength=idval='';
		  	    if($.cookie(defaults.cookieid)==null){
		  			var oldidlist=new Array();
		  		}else{
		  			var oldidlist=$.cookie(defaults.cookieid).split(",");
		  		}
		  	    
		  	    Arrlength=oldidlist.length;
		  	    
		  	    
		  		$(defaults.tableid +" input[type="+defaults.type+ "]").each(function(key) { 
		  			idval=parseInt($(this).val());
		  	    	newkey=parseInt(Arrlength+key);
		  	    	
		  			if(this.checked==true){
		  				this.checked = false;
		  				$(this).closest("tr").removeClass("onchicked");
		  				//去掉选中的ID
		  				if (!isNaN(idval)) {
		  					newidlist[key]=parseInt($(this).val());
			  	    	}
		  				newidstring=inANotInB(oldidlist,newidlist);
		  				
		  			}else{
		  				this.checked=true;
		  				$(this).closest("tr").addClass("onchicked");
		  				//增加反选的ID
			  	    	if (!isNaN(idval)) {
			  	    		oldidlist[newkey]=parseInt($(this).val());
			  	    	}
			  	    	newidstring=oldidlist;
		  			}
		  		});
		  		
		  	    //最后设置cookie
		  	    $.cookie(defaults.cookieid, newidstring); // set cookie
		  	    
		  		
		  	});
	 },
	//顶部全选
	 selectedall: function(obj,options) {
		  	$(obj).bind('click', function() {
		  		var defaults = {
		  		  	tableid:'.tableborder',
		  		  	cookieid:'Select_Id_list',
		  		  	type: 'checkbox'
			  	};
		  		$.extend(defaults,options);
		  	    //先取得到cookie值
		  	    var  oldidlist=newidlist=new Array();
		  	    var  newidstring=newkey=Arrlength=idval='';
		  	    if($.cookie(defaults.cookieid)==null){
		  			var oldidlist=new Array();
		  		}else{
		  			 var oldidlist=$.cookie(defaults.cookieid).split(",");
		  		}
		  	    Arrlength=oldidlist.length;
		  	    
		  		if(this.checked){  
		  	    	$(defaults.tableid +" input[type="+defaults.type+ "]").each(function(key) { 
			  	    		this.checked = true;
			  	    		idval=parseInt($(this).val());
				  	    	newkey=parseInt(Arrlength+key);
				  	    	if (!isNaN(idval)) {
				  	    		oldidlist[newkey]=parseInt($(this).val());
				  	    	}
				  	    	newidstring=oldidlist;
			  	    });
		  	    
		  	    	$(defaults.tableid +" tr").each(function() {$(this).addClass("onchicked")});
		  	    }else{  
		  	    	$(defaults.tableid +" input[type="+defaults.type+ "]").each(function(key) { 
		  	    		this.checked = false;
		  	    		//去掉选中的ID
		  	    		idval=parseInt($(this).val());
		  				if (!isNaN(idval)) {
		  					newidlist[key]=parseInt($(this).val());
			  	    	}
		  	    	});
		  	    	newidstring=inANotInB(oldidlist,newidlist);
		  	    	$(defaults.tableid +" tr").each(function() {$(this).removeClass("onchicked")});
		  	    }
		  		
		  	    //最后设置cookie
		  	    $.cookie(defaults.cookieid, newidstring); // set cookie
		  	   
				
		  	});
	 }
});